{include file="public/header" /}
<script charset="utf-8" src="/public/static/admin/myeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="/public/static/admin/myeditor/lang/zh_CN.js"></script>
<script type="text/javascript" src="/public/static/admin/layui/layui.js"></script>
<link rel="stylesheet" type="text/css" href="">
<!-- <script charset="utf-8" src="http://zsms.net/Manage/Admin/Public/myeditor/kindeditor-min.js"></script> -->
<!-- <script charset="utf-8" src="http://zsms.net/Manage/Admin/Public/myeditor/lang/zh_CN.js"></script> -->
<?php $i=0;?>
<script>
    KindEditor.ready(function(K) {
        var editor1 = K.create('.editor_id', {
            filterMode: false,//是否开启过滤模式
            cssPath : '/public/static/admin/myeditor/plugins/code/prettify.css',
            uploadJson : '/public/static/admin/myeditor/php/upload_json.php',
            fileManagerJson : '/public/static/admin/myeditor/php/file_manager_json.php',
            allowFileManager : true,
            afterBlur : function() {
                this.sync();
                K.ctrl(document, 13, function() {
                    K('form[name=formlist]')[0].submit();
                });
                K.ctrl(this.edit.doc, 13, function() {
                    K('form[name=formlist]')[0].submit();
                });
            }
        });

        var editor = K.editor({
            allowFileManager : true
        });
    {for start="1" end="config('BANNER_NUM')+1"}
            K('#img{$i}_btn').click(function() {
                editor.loadPlugin('image', function() {
                    editor.plugin.imageDialog({
                        imageUrl : K('#img{$i}').val(),
                        clickFn : function(url, title, width, height, border, align) {
                            K('#img{$i}').val(url);
                            editor.hideDialog();
                        }
                    });
                });
            });
    {/for}

        {if condition="in_array(11,$arr)"}
            K('#insert_file1').click(function() {
                editor.loadPlugin('insertfile', function() {
                    editor.plugin.fileDialog({
                        fileUrl : K('#file1').val(),
                        clickFn : function(url, title) {
                            K('#file1').val(url);
                            editor.hideDialog();
                        }
                    });
                });
            });
    {/if}

        {if condition="in_array(16,$arr)"}
            K('#images').click(function() {
                editor.loadPlugin('multiimage', function() {
                    editor.plugin.multiImageDialog({
                        clickFn : function(urlList) {
                            var div = K('#imagesview');
                            div.html('');
                            var urls = '';
                            K.each(urlList, function(i, data) {
                                div.append('<div style="width: 100px; float:left; padding-right: 10px;"><img src="' + data.url + '" width="100"><br><input type="text" placeholder="输入图片标题"  name="' + data.url + '" class="layui-input"></div>');
                                urls = urls+data.url+'|';
                            });

                            $("#imgurl").val(urls);
                            editor.hideDialog();
                        }
                    });
                });
            });
    {/if}
    });


    
</script>

<div class="layui-layout layui-layout-admin">
	{include file="public/left" /}
	<div class="layui-body">
		<div class="layui-tab layui-tab-brief" lay-filter="tab">
			<ul class="layui-tab-title">
				<li><a href="{$url}">{$v.catname}</a></li>
				<li class="layui-this"><a href="{$v.addurl}">{$v.catname}添加</a></li>
			</ul>
			<div class="layui-tab-content">
				<div class="layui-tab-item layui-show">
					<form action="" method="post" name="formlist" class="layui-form" lay-filter="content" id="edit">
						<input type="hidden" name="id" value="{$v.id}">
						<input type="hidden" name="pid" value="{$v.pid}">
						<input type="hidden" name="ty" value="{$v.ty}">
						<input type="hidden" name="tty" value="{$v.tty}">
						<input type="hidden" name="ttty" value="{$v.ttty}">

						{if condition="in_array(1,$arr)"}
							<div class="layui-form-item">
								<label class="layui-form-label">信息标题</label>
								<div class="layui-input-inline">
									<input type="text" name="title" value="{$v.title}" required lay-verify="required" placeholder="请输入内容标题" class="layui-input">
								</div>

								{if condition="in_array(3,$arr)"}<input type="checkbox" class="checkbox" lay-skin='primary' name="isgood" value="1" title="推荐" {:get_my_checked($v['isgood'],1)}>{/if}
								{if condition="in_array(4,$arr)"}<input type="checkbox" class="checkbox" lay-skin='primary' name="istop" value="1" title="置顶" {:get_my_checked($v['istop'],1)}>{/if}

							</div>
						{/if}

						{if condition="in_array(2,$arr)"}
							<div class="layui-form-item">
								<label class="layui-form-label">信息标签</label>
								<div class="layui-input-inline">
									<input type="text" name="tags" value="{$v.tags}" placeholder="请输入信息标签" class="layui-input">
								</div>
							</div>
						{/if}

						{if condition="in_array(14,$arr)"}
							<div class="layui-form-item">
								<label class="layui-form-label">价格</label>
								<div class="layui-input-inline">
									<input type="text" name="price" required lay-verify="required" value="{$v.price}" placeholder="请输入价格" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">删除线[价格]</label>
								<div class="layui-input-inline">
									<input type="text" name="price2" required lay-verify="required" value="{$v.price2}" placeholder="请输入删除线[价格]" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">销量</label>
								<div class="layui-input-inline">
									<input type="text" name="num" required lay-verify="required" value="{$v.num}" placeholder="请输入销量" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">库存</label>
								<div class="layui-input-inline">
									<input type="text" name="stock" required lay-verify="required" value="{$v.stock}" placeholder="请输入库存" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">预览量</label>
								<div class="layui-input-inline">
									<input type="text" name="hits" required lay-verify="required" value="{$v.hits}" placeholder="请输入预览量" class="layui-input">
								</div>
							</div>
						{/if}

						{if condition="in_array(5,$arr)"}
							<div class="layui-form-item">
								<label class="layui-form-label">外部链接</label>
								<div class="layui-input-inline">
									<input type="text" name="linkurl" value="{$v.linkurl}" placeholder="请输入外部链接" class="layui-input">
								</div>
							</div>
						{/if}

						{if condition="in_array(6,$arr)"}
							<div class="layui-form-item">
								<label class="layui-form-label">内容摘要</label>
								<div class="layui-input-inline">
									<textarea name="introduce" style="width:520px;height:100px;" class="layui-textarea">{$v.introduce}</textarea>
								</div>
							</div>
						{/if}

						{if condition="in_array(7,$arr)"}
							<div class="layui-form-item">
								<label class="layui-form-label">SEO关键字</label>
								<div class="layui-input-inline">
									<input type="text" name="seokeywords" value="{$v.seokeywords}" placeholder="请输入SEO关键字" class="layui-input">
								</div>
							</div>
						{/if}

						{if condition="in_array(8,$arr)"}
							<div class="layui-form-item">
								<label class="layui-form-label">SEO描述</label>
								<div class="layui-input-inline">
									<textarea name="seodescription" style="width:520px;height:100px;" class="layui-textarea">{$v.seodescription}</textarea>
								</div>
							</div>
						{/if}


						{if condition="in_array(9,$arr)"}
							<div class="layui-form-item">
								<label class="layui-form-label">内容详情</label>
								<div class="layui-input-block">
									<textarea class="editor_id" name="content" style="width:667px;height:350px;">{$v.content}</textarea>                            </div>
							</div>
						{/if}

						{if condition="in_array(10,$arr)"}
							{for start="1" end="config('BANNER_NUM')+1"}
								<?php
									$zd="img$i";?>
								<div class="layui-form-item">
									<label class="layui-form-label">配置文件</label>
									<div class="layui-input-inline">
										<input type="text" name="img{$i}" id="img{$i}" value="{$v[$zd]}" placeholder="请上传配置图片"  class="layui-input">
									</div>
									<button type="button" id="img{$i}_btn" class="layui-btn" data-des="ico">
										<i class="layui-icon">&#xe67c;</i>上传图片
									</button>
									{:get_img_show($v[$zd])}
									<font color="red">图片大小:{:get_cfg_var("post_max_size")}内,图片尺寸：{:get_imgsize($i,$v['pid'],$v['ty'],$v['tty'])}px</font>
								</div>
								<?php
									$i++;
								?>
							{/for}
						{/if}

						{if condition="in_array(16,$arr)"}
							
							<div class="layui-form-item">
								<label class="layui-form-label">详情顶部图</label>
								<div class="layui-upload">
								  <button type="button" class="layui-btn" id="test2">多图片上传</button> 
								  <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
								    预览图：<font color="red">图片大小:{:get_cfg_var("post_max_size")}内,图片尺寸：{:get_sort_zd($v['zid'],'titleimgsize')}px</font>
								    <div class="layui-upload-list" id="demo2" style="">
										{volist name=":get_titlepic($v['id'],$v['ty'],$v['tty'],$v['ttty'])" id="vv"}
											<div style="position: relative;display:inline-block;width: 120px;padding-right: 10px;">
												<a target="_blank" href="{:get_img($vv['img1'])}"  >
													<img src="{:get_img($vv['img1'])}" alt="{:get_img($vv['img1'])}" style="width: 120px;">
												</a>
												<br>
												<!-- <input type="text" placeholder="输入图片标题"  value="{$vv.title}" name="tit[]" class="layui-input"> -->
												<input type="hidden"  value="{:get_img($vv['img1'])}" name="imgurl[]" class="layui-input">
												<input type="hidden"  value="{$vv.id}" name="ids[]" class="layui-input">
												<span id="{$vv.id}" style="position: absolute;right:0; top:0;display:inline-block; width:20px; height:20px; background:#000; color:#FFF;line-height:20px; font-size:20px; text-align:center;cursor:pointer;">×</span>
											</div>
										{/volist}
								    </div>
								 </blockquote>
								</div>
							</div>
							<script>
								$(function(){

									var upload = layui.upload; //得到 upload 对象
									$.getJSON('test/photos.json?v='+new Date, function(json){
									  layer.photos({
									    photos: json //格式见API文档手册页
									    ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机
									  });
									});
									//多图片上传
									  upload.render({
									    elem: '#test2'
									    ,url: "{:url('Products/uploads')} "//此处配置你自己的上传接口即可
									    ,multiple: true
									    ,before: function(obj){
									      //预读本地文件示例，不支持ie8
									      // obj.preview(function(index, file, result){
									      //   $('#demo2').append('<div style="width: 100px; float:left; padding-right: 10px;"><a href="'+ result +'"  ><img src="'+ result +'" alt="'+ file.name +'" style="width: 92px;height: 92px;"></a><br><input type="text" placeholder="输入图片标题"  value="" name="tit" class="layui-input"><input type="hidden"  value="" name="tit" class="layui-input"></div>')
									      // });
									    }
									    ,done: function(res){
									    	$('#demo2').append('<div style="position: relative;display:inline-block;width: 120px;padding-right: 10px;"><a target="_blank" href="'+ res.msg +'"  ><img src="'+ res.msg +'" alt="'+ res.msg +'" style="width: 120px;"></a><!--<br><input type="text" placeholder="输入图片标题"  value="" name="tit[]" class="layui-input">--><input type="hidden"  value="'+ res.msg +'" name="imgurl[]" class="layui-input"><input type="hidden"  value="0" name="ids[]" class="layui-input"><span id="0" style="position: absolute;right:0; top:0;display:inline-block; width:20px; height:20px; background:#000; color:#FFF;line-height:20px; font-size:20px; text-align:center;cursor:pointer;">×</span></div>')
									    }
									  });

									// 删除详情图
									$('#demo2').on('click','span',function(){
									   if($(this).attr('id')){
									   	var index = $(this);
									   	var v = $(this).attr('id');
									   	var urlData={id:v,imgUrl:index.prev('input').prev('input').val()};
									   	// alert(v);
									   	// return false;
									   	//询问框
										layer.confirm('您是否操作删除？', {
										  btn: ['确定','取消'] //按钮
										}, function(){
											$.post('/Admin/Products/Titlepic',urlData,function(data){
												index.parent('div').hide();
								            	layer.msg('删除成功', {icon: 1});
								            });
										}, function(){
										  layer.msg('取消了删除', {icon: 2});
										});

							            
									   }
									})

								});
							</script> 

							<div class="layui-form-item">
								<label class="layui-form-label">底部图文详情</label>
								<div class="layui-upload">
								  <button type="button" class="layui-btn" id="test3">多图片上传</button> 
								  <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
								    预览图：<font color="red">图片大小:{:get_cfg_var("post_max_size")}内,图片尺寸：750px*(高度自适应)</font>
								    <div class="layui-upload-list" id="demo3" style="">
										{volist name=":get_titlepic($v['id'],$v['ty'],$v['tty'],$v['ttty'],1)" id="vv"}
											<div style="position: relative;display:inline-block;width: 120px;padding-right: 10px;">
												<a target="_blank" href="{:get_img($vv['img1'])}"  >
													<img src="{:get_img($vv['img1'])}" alt="{:get_img($vv['img1'])}" style="width: 120px;">
												</a>
												<br>
												<!-- <input type="text" placeholder="输入图片标题"  value="{$vv.title}" name="wt_tit[]" class="layui-input"> -->
												<input type="hidden"  value="{:get_img($vv['img1'])}" name="wt_imgurl[]" class="layui-input">
												<input type="hidden"  value="{$vv.id}" name="wt_ids[]" class="layui-input">
												<span id="{$vv.id}" style="position: absolute;right:0; top:0;display:inline-block; width:20px; height:20px; background:#000; color:#FFF;line-height:20px; font-size:20px; text-align:center;cursor:pointer;">×</span>
											</div>
										{/volist}
								    </div>
								 </blockquote>
								</div>
							</div>
							<script>
								$(function(){

									var upload = layui.upload; //得到 upload 对象
									//多图片上传
									  upload.render({
									    elem: '#test3'
									    ,url: "{:url('Products/uploads')} "//此处配置你自己的上传接口即可
									    ,multiple: true
									    ,done: function(res){
									    	$('#demo3').append('<div style="position: relative;display:inline-block;width: 120px;padding-right: 10px;"><a target="_blank" href="'+ res.msg +'"  ><img src="'+ res.msg +'" alt="'+ res.msg +'" style="width: 120px;"></a><!--<br><input type="text" placeholder="输入图片标题"  value="" name="wt_tit[]" class="layui-input">--><input type="hidden"  value="'+ res.msg +'" name="wt_imgurl[]" class="layui-input"><input type="hidden"  value="0" name="wt_ids[]" class="layui-input"><span id="0" style="position: absolute;right:0; top:0;display:inline-block; width:20px; height:20px; background:#000; color:#FFF;line-height:20px; font-size:20px; text-align:center;cursor:pointer;">×</span></div>')
									    }
									  });

									// 删除详情图
									$('#demo3').on('click','span',function(){
									   if($(this).attr('id')){
									   	var index = $(this);
									   	var v = $(this).attr('id');
									   	var urlData={id:v,imgUrl:index.prev('input').prev('input').val()};
									   	// console.log(urlData);
									   	// return false;
									   	//询问框
										layer.confirm('您是否操作删除？', {
										  btn: ['确定','取消'] //按钮
										}, function(){
											$.post('/Admin/Products/Titlepic',urlData,function(data){
												index.parent('div').hide();
								            	layer.msg('删除成功', {icon: 1});
								            });
										}, function(){
										  layer.msg('取消了删除', {icon: 2});
										});

							            
									   }
									})

								});
							</script> 

						{/if}

						{if condition="in_array(11,$arr)"}
							<div class="layui-form-item">
								<label class="layui-form-label">文件上传</label>
								<div class="layui-input-inline">
									<input type="text" name="file1" id="file1" value="{$v.file1}" placeholder="请选择文件上传" class="layui-input">
								</div>
								<button type="button" id="insert_file1" class="layui-btn" data-des="enclosure">
									<i class="layui-icon">&#xe67c;</i>上传附件
								</button>

								<font color="#FF0000">文件大小:{:get_cfg_var("post_max_size")}</font>
							</div>
						{/if}

						{if condition="in_array(12,$arr)"}
							<div class="layui-form-item">
								<label class="layui-form-label">来源</label>
								<div class="layui-input-inline">
									<input type="text" name="source" value="{$v.source}" placeholder="请输入来源" class="layui-input">
								</div>
							</div>
						{/if}


						{if condition="in_array(13,$arr)"}
							<div class="layui-form-item">
								<label class="layui-form-label">作者</label>
								<div class="layui-input-inline">
									<input type="text" name="author" value="{$v.author}" placeholder="请输入作者" class="layui-input">
								</div>
							</div>
						{/if}

						

						{if condition="in_array(15,$arr)"}
							<div class="layui-form-item">
								<label class="layui-form-label">人气</label>
								<div class="layui-input-inline">
									<input type="text" name="hits" value="{$v.hits}" placeholder="请输入人气" class="layui-input">
								</div>
							</div>
						{/if}

						<div class="layui-form-item">
							<div class="layui-input-block">
								<button class="layui-btn" lay-submit >立即提交</button>
								<button type="reset" class="layui-btn layui-btn-primary">重置</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>

	{include file="public/footer" /}
</div>

</body>
</html>
